﻿using System.Collections.Generic;

namespace Isaac.Joy.Identity.Module
{
    public interface IRepository
    {
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        User AddUser(User user);

        /// <summary>
        /// 获取用户
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        User GetUser(int id);

        /// <summary>
        /// 验证用户
        /// </summary>
        /// <param name="loginid">登录名</param>
        /// <param name="pwd">密码</param>
        /// <returns></returns>
        User AuthorizeUser(string loginid, string pwd);

        /// <summary>
        /// 编辑用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        bool EditUser(User user);

        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        int DeleteUser(int[] ids);

        /// <summary>
        /// 查询用户
        /// </summary>
        /// <param name="pageindex"></param>
        /// <param name="pagesize"></param>
        /// <param name="datacount"></param>
        /// <param name="wd"></param>
        /// <param name="rid"></param>
        /// <returns></returns>
        IEnumerable<User> QueryUser(int pageindex, int pagesize, out int datacount, string wd = null, int? rid = 0);

        /// <summary>
        /// 获取所有角色
        /// </summary>
        /// <returns></returns>
        IEnumerable<Role> GetRoles();

        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        Role AddRole(Role role);

        /// <summary>
        /// 获取角色信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Role GetRole(int id);

        /// <summary>
        /// 编辑角色信息
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        bool EditRole(Role role);

        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        int DeleteRole(int[] ids);

        /// <summary>
        /// 查询角色
        /// </summary>
        /// <param name="pageindex"></param>
        /// <param name="pagesize"></param>
        /// <param name="datacount"></param>
        /// <returns></returns>
        IEnumerable<Role> QueryRole(int pageindex, int pagesize, out int datacount);

        /// <summary>
        /// 获取所有权限
        /// </summary>
        /// <returns></returns>
        IEnumerable<Permission> GetPermissions();

        /// <summary>
        /// 获取权限信息
        /// </summary>
        /// <param name="code"></param>
        /// <param name="plugin"></param>
        /// <returns></returns>
        Permission GetPermission(string code, string plugin);
    }
}
